package com.orangelife.mobile.parkingcard.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.curry.orangelife.mobile.R;
import com.curry.android.adapter.FatherAdapter;

import java.util.List;
import java.util.Map;

public class CarNumListAdapter<T>  extends FatherAdapter<T> {

	private List<Map<String,Object>> list;
	private Context context;

	public CarNumListAdapter(Context context, List<Map<String, Object>> list) {
		this.list = list;
		this.context = context;
	}

	
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}
   
	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.item_car_manage, null);
			viewHolder.tvCarNum = (TextView) convertView
					.findViewById(R.id.tvCarNum);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}

		viewHolder.tvCarNum.setText(String.valueOf(list.get(position).get("num_plate")));

		return convertView;
	}

	class ViewHolder {
		TextView tvCarNum;
	}

	@Override
	public BaseAdapter setList(List<T> list) {
		this.list = (List<Map<String, Object>>) list;
		return CarNumListAdapter.this;
	}

}
